package com.yun.space.pro.search.action;

import com.opensymphony.xwork2.ActionContext;
import com.yun.space.base.BaseAction;
import com.yun.space.entity.Search;

/**
 * 资讯中心相关的action
 * @author guo
 *
 */
public class SearchAction extends BaseAction<Search>{

	/*
	 * 	@guo 
	 *  进入搜索页面
	 */
	private Search search = null;
	public String searchResults(){
		Integer type= getModel().getType();
		if(getModel().getUuid() != null ){
			if(getModel().getUuid().length()==15){
				String temp = getModel().getUuid();
				String str1=temp.substring(0, 3) ;
				String str2=temp.substring(3, 6) ;
				String str3=temp.substring(6, 9) ;
				String str4=temp.substring(9, 12) ;
				String str5=temp.substring(12, 15) ;
				if(type==1){
					search = searchService.findByUUID(str1,1);
				}else if(type==2){
					search = searchService.findByUUID(str2,2);
				}else if(type==3){
					search = searchService.findByUUID(str3,3);
				}else if(type==4){
					search = searchService.findByUUID(str4,4);
				}else if(type==5){
					search = searchService.findByUUID(str5,5);
				}
				ActionContext.getContext().getValueStack().set("uuid",getModel().getUuid());
				ActionContext.getContext().getValueStack().set("search",search);
			}else{
				search=new Search();
				search.setContexts("你输入的编码不正确！");
				ActionContext.getContext().getValueStack().set("search",search);
				ActionContext.getContext().getValueStack().set("uuid",getModel().getUuid());
			}
		}else{
			search=new Search();
			search.setContexts("你输入的编码不正确！");
			ActionContext.getContext().getValueStack().set("search",search);
			ActionContext.getContext().getValueStack().set("uuid",getModel().getUuid());
		}
		return "searchResults";
	}
}
